/*
 * @Author: your name
 * @Date: 2020-12-18 10:21:34
 * @LastEditTime: 2020-12-23 18:27:55
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \gitee-WeBi\js\zz\add_reportForm\index.js
 */
$.when($.ready).done(function(){
    new Vue({
        el:"#zz-main_iframe",


        mixins:[
            zzMixinBI,
            zzMixinSetRem,
            ARF_table_rf, // 表格报表相关
            ARF_zxt_rf, // 折线图报表相关
            ARF_zzt_rf, // 柱状图报表相关
            ARF_bzt_rf, // 饼状图报表相关
        ],


        data:{
            // --- 报表类型
            reportType:"2",
            // --- 报表分类
            reports:{
                "0":{ // --- 表格
                    //id:"", // --- 图表id
                    //chart_dom: null, // --- 图表dom
                    //chart:null // --- 图表
                },
                "1":{ // --- 折线图
                    id:"zxt-test", // --- 图表id
                    chart_dom: null, // --- 图表dom
                    chart:null, // --- 图表
                    optionName:"zxt_options"
                },
                "2":{ // --- 柱状图
                    id:"zzt-test", // --- 图表id
                    chart_dom: null, // --- 图表dom
                    chart:null, // --- 图表
                    optionName:"zzt_options"
                },
                "3":{
                    id:"", // --- 图表id
                    chart_dom: null, // --- 图表dom
                    chart:null // --- 图表
                }
            }

        },


        computed:{


        },


        created(){


        },


        mounted(){
            console.log("---this.zzt_options---",this.zzt_options);
            //var zxt_chart = echarts.init(ARF_calc_dom.calcSingle("zxt-test"));
            //var zzt_chart = echarts.init(ARF_calc_dom.calcSingle("zzt-test"));

            //zxt_chart.setOption(this.zxt_options);
            //zzt_chart.setOption(this.zzt_options);
            // var rt = this.reportType;
            // this.$set(this.reports[rt],"chart_dom",ARF_calc_dom.calcSingle(this.reports[rt].id));
            // this.$set(this.reports[rt],"chart",echarts.init(this.reports[rt].chart_dom));
            // this.reports[rt].chart.setOption(this[this.reports[rt].optionName]);
            this.initChart();
        },


        watch:{
            // --- 报表类型
            reportType(val){
                if(val=="0"||val=="3")return;
                var _this = this;
                if(!this.reports[val].chart_dom){
                    this.$nextTick().then(function(){
                        _this.initChart();
                    });
                }
            }

        },


        methods:{
            /* ---S */
            // --- 初始化图表
            initChart(){
                var rt = this.reportType;
                this.$set(this.reports[rt],"chart_dom",ARF_calc_dom.calcSingle(this.reports[rt].id));
                this.$set(this.reports[rt],"chart",echarts.init(this.reports[rt].chart_dom));
                this.reports[rt].chart.setOption(this[this.reports[rt].optionName]);
            },
            // --- 返回报表页
            backToConfigReportForm(){
                //alert("backToConfigReportForm");
                top.zzTabs1.showTab().then(function(){
                    top.zzTabs1.tabAdd({
                        url:"../config_reportForm/index.html"
                    });
                });
            }
            /* ---E */

        },


        components:{


        }


    })
});
